package com.xls.pet.exception;

import com.xls.pet.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    /**
     * 自定义异常-业务
     */
    @ExceptionHandler(BusinessException.class)
    public Result<String> error(BusinessException e) {
        log.error(e.getErrorMessage());
        return new Result<>(e.getCode(), e.getErrorMessage());
    }

}
